/*
  Calculating a problem set's score based on the score of the teams
  Sol: Simultation
*/

#include <iostream>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>

using namespace std;

int prob[20];
string s;
int c, p;
int point, ntest = 0;

int main()
{
	while (scanf("%d %d \n", &c, &p))
	{
		if (c == 0 && p == 0) break;

		int solvedCount = 0, solvedComplete = 0;
		memset(prob, 0, sizeof(prob));

		for (int i = 0; i < c; i++)
		{
			getline(cin, s);
			int pos = s.find(' ');
			s = s.substr(pos+1, s.size()-1-pos);	// ignore the name of the teams
			istringstream ss(s);

			int teamSolved = 0;
			for (int j = 0; j < p; j++)
			{
				int a;
				ss >> a;
				prob[j] += a;

				if (a == 1) teamSolved++;
			}
			if (teamSolved >= 2) solvedCount++;
			if (teamSolved == p) solvedComplete++;
		}

		// fairness
		point = 1;
		for (int i = 0; i < p; i++)
			if (prob[i] == 0) {
				point--;
				break;
			}

		// inclusive
		if (solvedCount*10 > c*9) point += 2;

		// challenge
		if (solvedComplete == 0) point += 2;

		cout << "Contest " << (++ntest) << ": " << point << endl;
	}
	return 0;
}
